package com.example.demo.firemain.data;



import com.example.demo.firemain.ByteUtil;
import com.example.demo.firemain.NumConstant;
import lombok.Data;

/**
 * 火灾主要地位
 * 用户信息传输装置操作
 *
 * @author TDS
 * @date 2022/08/23
 */
@Data
public class FireMainStatus {

	/**
	 * 系统类型//消防主机类型
	 */
	private Integer systemType;
	/**
	 * 系统代码//消防主机编号
	 */
	private Integer systemCode;
	/**
	 * 状态//消防主机状态
	 */
	private String status;

	private String device_id;


    public FireMainStatus(String data , String deviceId){
    	this.device_id = deviceId;

		systemType = Integer.parseInt(data.substring(4,6),16);
		systemCode = Integer.parseInt(data.substring(6,8),16);
		String bit = ByteUtil.buqi(Integer.toBinaryString(Integer.parseInt(data.substring(8,12),16)));
		if (NumConstant.ONE.equals(bit.substring(15,16))){
			status = "正常状态";
		}else if (NumConstant.ONE.equals(bit.substring(14,15))){
			status = "火警";
		}else if (NumConstant.ONE.equals(bit.substring(13,14))){
			status = "故障";
		}else if (NumConstant.ONE.equals(bit.substring(12,13))){
			status = "屏蔽";
		}else if (NumConstant.ONE.equals(bit.substring(11,12))){
			status = "监管";
		}else if (NumConstant.ONE.equals(bit.substring(10,11))){
			status = "启动";
		}else if (NumConstant.ONE.equals(bit.substring(9,10))){
			status = "反馈";
		}
		else if (NumConstant.ONE.equals(bit.substring(8,9))){
			status = "延时状态";
		}else if (NumConstant.ONE.equals(bit.substring(7,8))){
			status = "主电故障";
		}else if (NumConstant.ONE.equals(bit.substring(6,7))){
			status = "备电故障";
		}else if (NumConstant.ONE.equals(bit.substring(5,6))){
			status = "总线故障";
		}else if (NumConstant.ONE.equals(bit.substring(4,5))){
			status = "手动状态";
		}else if (NumConstant.ONE.equals(bit.substring(3,4))){
			status = "配置改变";
		}else if (NumConstant.ONE.equals(bit.substring(2,3))){
			status = "复位";
		}
		else if (NumConstant.ONE.equals(bit.substring(1,2))){
			status = "预留";
		}
		else if (NumConstant.ONE.equals(bit.substring(0,1))){
			status = "预留";
		}
		else{
			status = "无异常";
		}
    }
}
